import { http } from "@/utils/http";
import { ListResult } from "./models";


export type CtaType = 'form' | 'wechat_qrcode' | 'work_qrcode' | '';
export type CtaInfoType = [CtaType, string];

export type QuestionCode = 'name' | 'mobile' | 'mobile_code' | 'email' | 'email_code' | 'company' | 'position' | 'address' | 'sex';
/** 获取内容列表 */
export type Question = {
  label: string,
  code: QuestionCode
}
export interface ctaInfoType {
  uuid:string
  mid:number
  name:string
  type:string
  work_qrcode?:{
    guide: string
    reply: string
    member:string
  },
  wechat_qrcode?:{
    guide: string
    reply: string
  },
  form?: {
    thumb:string
    material_uuid:string
    question:Question[]
  }
  qrcode_url?:string
}
export const ctaInfo = (uuid: string,entityType:string,entityUuid:string) => {
  return http.request<ListResult<ctaInfoType>>("get", `/api/open/resource/cta/show/${uuid}/${entityType}/${entityUuid}`);
}


export interface ctaStatusType {
  status: boolean
  type: string
  qrcode_url: string
  mobile: string
  email: string
  name: string
}
export const ctaStatusInfo = (data: object) => {
  return http.request<ListResult<ctaStatusType>>("post", '/api/open/nurturing/user/ctaStatus',{
    data
  });
}


interface emailDownloadType{
  email:boolean
  send:boolean
}

export const emailDownload = (data: object) => {
  return http.request<ListResult<emailDownloadType>>("post", '/api/open/nurturing/user/emailDownload',{
    data
  });
}

interface checkPassType {
  status: boolean
}
export const ctaCheckPass = (data: object) => {
  return http.request<ListResult<checkPassType>>("post", '/api/open/nurturing/user/checkPass',{
    data
  });
}

interface ctaFormSubmitType {
  uuid: string
}
export const ctaFormSubmit = (data: object) => {
  return http.request<ListResult<ctaFormSubmitType>>("post", '/api/open/resource/cta/submit',{
    data
  });
}


interface ctaDownloadWechatType {
  url: string
}
export const ctaDownloadWechat = (data: object) => {
  return http.request<ListResult<ctaDownloadWechatType>>("post", '/api/open/resource/content/downloadWechat',{
    data
  });
}